<template>
    <div>
        <!-- 加载PDF文件 -->
        <pdf v-for="i in numPages" :key="i" :src="url" :page="i" style="width: 100%; margin-bottom: 15px;"></pdf>
    </div>
</template>

<script>
import pdf from 'vue-pdf'

export default {
    components: {
        pdf
    },
    data() {
        return {
            url: 'https://dkd-cc.oss-cn-beijing.aliyuncs.com/dkd-images/2024/12/17/67613567804ab648c01a3abf.pdf',
            numPages: undefined
        }
    },
    methods: {
        loadPdf() {
            const loadingTask = pdf.createLoadingTask(this.url);
            loadingTask.promise.then(pdf => {
                this.numPages = pdf.numPages;
            }).catch(err => {
                console.error('加载PDF失败:', err);
            });
        }
    },
    mounted() {
        this.loadPdf();
    }
}
</script>